﻿Imports System.Data.Linq
Imports System.Linq

Public Class MMBL
    Private db As New TanNamChinhDataContext
    
    
    Public Function getIDMBL(ByVal id_file As Integer) As Integer
        Dim id As Integer
        Try
            id = (From fm In db.tblFileMBLs
                   Where fm.ID_File = id_file
                   Order By fm.ID_MBL
                   Select fm.ID_MBL).First
        Catch ex As Exception
            Throw ex
        End Try
        Return id
    End Function
    Public Function getIDVoyage(ByVal id_mbl As Integer) As Integer
        Dim id As Integer
        Try
            id = (From fm In db.tblMBLs
                   Where fm.ID_MBL = id_mbl
                   Order By fm.ID_Voyage
                   Select fm.ID_Voyage
                   ).First
        Catch ex As Exception
            Throw ex
        End Try
        Return id
    End Function
  
    'Sub FillDriverCombo(ByVal combo As DataGridViewComboBoxColumn)
    '    Dim query As Object

    '    ' If My.Application.ActiveRoleId = 2 Then
    '    query = From a In db.tblDrivers
    '                   Select a.ID_Driver, a.DriverName
    '                   Order By DriverName Ascending
    '    'Else
    '    'query = From a In db.customers
    '    '            Select a.id, a.name
    '    '            Order By name Ascending
    '    'End If


    '    If Not IsNothing(query) Then
    '        With combo
    '            .DataSource = query
    '            .DisplayMember = "DriverName"
    '            .ValueMember = "ID_Driver"
    '        End With
    '    End If
    'End Sub
    Public Function GetContList(ByVal idFile As Integer) As IQueryable
        Dim query = From b In db.tblConts
                    Where b.ID_File = idFile
                    Select b

        Return query
    End Function
     

End Class
